{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "\n",
    "\n",
    "def sample_data(shape=(73, 145)):\n",
    "    nlats, nlons = shape\n",
    "    lats = np.linspace(-np.pi / 2, np.pi / 2, nlats)\n",
    "    lons = np.linspace(0, 2 * np.pi, nlons)\n",
    "    lons, lats = np.meshgrid(lons, lats)\n",
    "    wave = 0.75 * (np.sin(2 * lats) ** 8) * np.cos(4 * lons)\n",
    "    mean = 0.5 * np.cos(2 * lats) * ((np.sin(2 * lats)) ** 2 + 2)\n",
    "\n",
    "    lats = np.rad2deg(lats)\n",
    "    lons = np.rad2deg(lons)\n",
    "    data = wave + mean\n",
    "\n",
    "    return lons, lats, data\n",
    "\n",
    "\n",
    "lon, lat, data = sample_data(shape=(73, 145))\n",
    "lon -= 180"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "%matplotlib inline\n",
    "\n",
    "import matplotlib\n",
    "\n",
    "cm = matplotlib.cm.get_cmap(\"cubehelix\")\n",
    "\n",
    "normed_data = (data - data.min()) / (data.max() - data.min())\n",
    "colored_data = cm(normed_data)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Bad"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style=\"width:100%;\"><div style=\"position:relative;width:100%;height:0;padding-bottom:60%;\"><span style=\"color:#565656\">Make this Notebook Trusted to load map: File -> Trust Notebook</span><iframe src=\"about:blank\" style=\"position:absolute;width:100%;height:100%;left:0;top:0;border:none !important;\" data-html=PCFET0NUWVBFIGh0bWw+CjxoZWFkPiAgICAKICAgIDxtZXRhIGh0dHAtZXF1aXY9ImNvbnRlbnQtdHlwZSIgY29udGVudD0idGV4dC9odG1sOyBjaGFyc2V0PVVURi04IiAvPgogICAgCiAgICAgICAgPHNjcmlw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AgIGhlaWdodDogMTAwLjAlOwogICAgICAgICAgICAgICAgICAgIGxlZnQ6IDAuMCU7CiAgICAgICAgICAgICAgICAgICAgdG9wOiAwLjAlOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICA8L3N0eWxlPgogICAgICAgIAogICAgCiAgICAgICAgICAgICAgICA8c3R5bGU+CiAgICAgICAgICAgICAgICAgICAgLmxlYWZsZXQtaW1hZ2UtbGF5ZXIgewogICAgICAgICAgICAgICAgICAgICAgICAvKiBvbGQgYW5kcm9pZC9zYWZhcmkqLwogICAgICAgICAgICAgICAgICAgICAgICBpbWFnZS1yZW5kZXJpbmc6IC13ZWJraXQtb3B0aW1pemUtY29udHJhc3Q7CiAgICAgICAgICAgICAgICAgICAgICAgIGltYWdlLXJlbmRlcmluZzogY3Jpc3AtZWRnZXM7IC8qIHNhZmFyaSAqLwogICAgICAgICAgICAgICAgICAgICAgICBpbWFnZS1yZW5kZXJpbmc6IHBpeGVsYXRlZDsgLyogY2hyb21lICovCiAgICAgICAgICAgICAgICAgICAgICAgIGltYWdlLXJlbmRlcmluZzogLW1vei1jcmlzcC1lZGdlczsgLyogZmlyZWZveCAqLwogICAgICAgICAgICAgICAgICAgICAgICBpbWFnZS1yZW5kZXJpbmc6IC1vLWNyaXNwLWVkZ2VzOyAvKiBvcGVyYSAqLwogICAgICAgICAgICAgICAgICAgICAgICAtbXMtaW50ZXJwb2xhdGlvbi1tb2RlOiBuZWFyZXN0LW5laWdoYm9yOyAvKiBpZSAqLwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIDwvc3R5bGU+CiAgICAgICAgICAgIAo8L2hlYWQ+Cjxib2R5PiAgICAKICAgIAogICAgICAgICAgICA8ZGl2IGNsYXNzPSJmb2xpdW0tbWFwIiBpZD0ibWFwXzA4ZjcyOThhYjA1OTQ3NTk4NjNhZTEwZTNlZDU3NDY0IiA+PC9kaXY+CiAgICAgICAgCjwvYm9keT4KPHNjcmlwdD4gICAgCiAgICAKICAgICAgICAgICAgdmFyIG1hcF8wOGY3Mjk4YWIwNTk0NzU5ODYzYWUxMGUzZWQ1NzQ2NCA9IEwubWFwKAogICAgICAgICAgICAgICAgIm1hcF8wOGY3Mjk4YWIwNTk0NzU5ODYzYWUxMGUzZWQ1NzQ2NCIsCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgY2VudGVyOiBbMC4wLCAtOC41OTIyOTc2MDc2ODAwMDJlLTE3XSwKICAgICAgICAgICAgICAgICAgICBjcnM6IEwuQ1JTLkVQU0czODU3LAogICAgICAgICAgICAgICAgICAgIHpvb206IDEsCiAgICAgICAgICAgICAgICAgICAgem9vbUNvbnRyb2w6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgcHJlZmVyQ2FudmFzOiBmYWxzZSwKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgKTsKCiAgICAgICAgICAgIAoKICAgICAgICAKICAgIAogICAgICAgICAgICB2YXIgdGlsZV9sYXllcl81ZGU4Mjk0YjI5ZjE0ZDk4ODBkMjk3MTRjOTM0OWE3YSA9IEwudGlsZUxheWVyKAogICAgICAgICAgICAgICAgImh0dHBzOi8ve3N9LnRpbGUub3BlbnN0cmVldG1hcC5vcmcve3p9L3t4fS97eX0ucG5nIiwKICAgICAgICAgICAgICAgIHsiYXR0cmlidXRpb24iOiAiRGF0YSBieSBcdTAwMjZjb3B5OyBcdTAwM2NhIGhyZWY9XCJodHRwOi8vb3BlbnN0cmVldG1hcC5vcmdcIlx1MDAzZU9wZW5TdHJlZXRNYXBcdTAwM2MvYVx1MDAzZSwgdW5kZXIgXHUwMDNjYSBocmVmPVwiaHR0cDovL3d3dy5vcGVuc3RyZWV0bWFwLm9yZy9jb3B5cmlnaHRcIlx1MDAzZU9EYkxcdTAwM2MvYVx1MDAzZS4iLCAiZGV0ZWN0UmV0aW5hIjogZmFsc2UsICJtYXhOYXRpdmVab29tIjogMTgsICJtYXhab29tIjogMTgsICJtaW5ab29tIjogMCwgIm5vV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this.contentDocument.close();\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe></div></div>"
      ],
      "text/plain": [
       "<folium.folium.Map at 0x7f0aac36f430>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import folium\n",
    "\n",
    "\n",
    "m = folium.Map(location=[lat.mean(), lon.mean()], zoom_start=1)\n",
    "\n",
    "folium.raster_layers.ImageOverlay(\n",
    "    image=colored_data,\n",
    "    bounds=[[lat.min(), lon.min()], [lat.max(), lon.max()]],\n",
    "    opacity=0.25,\n",
    ").add_to(m)\n",
    "\n",
    "m"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Good"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style=\"width:100%;\"><div style=\"position:relative;width:100%;height:0;padding-bottom:60%;\"><span style=\"color:#565656\">Make this Notebook Trusted to load map: File -> Trust Notebook</span><iframe src=\"about:blank\" style=\"position:absolute;width:100%;height:100%;left:0;top:0;border:none !important;\" data-html=PCFET0NUWVBFIGh0bWw+CjxoZWFkPiAgICAKICAgIDxtZXRhIGh0dHAtZXF1aXY9ImNvbnRlbnQtdHlwZSIgY29udGVudD0idGV4dC9odG1sOyBjaGFyc2V0PVVURi04IiAvPgogICAgCiAgICAgICAgPHNjcmlwdD4KICAgICAgICAgICAgTF9OT19UT1VDSCA9IGZhbHNlOwogICAgICAgICAgICBMX0RJU0FCTEVfM0QgPSBmYWxzZTsKICAgICAgICA8L3NjcmlwdD4KICAgIAogICAgPHN0eWxlPmh0bWwsIGJvZHkge3dpZHRoOiAxMDAlO2hlaWdodDogMTAwJTttYXJnaW46IDA7cGFkZGluZzogMDt9PC9zdHlsZT4KICAgIDxzdHlsZT4jbWFwIHtwb3NpdGlvbjphYnNvbHV0ZTt0b3A6MDtib3R0b206MDtyaWdodDowO2xlZnQ6MDt9PC9zdHlsZT4KICAgI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IvPgogICAgPGxpbmsgcmVsPSJzdHlsZXNoZWV0IiBocmVmPSJodHRwczovL2NkbmpzLmNsb3VkZmxhcmUuY29tL2FqYXgvbGlicy9MZWFmbGV0LmF3ZXNvbWUtbWFya2Vycy8yLjAuMi9sZWFmbGV0LmF3ZXNvbWUtbWFya2Vycy5jc3MiLz4KICAgIDxsaW5rIHJlbD0ic3R5bGVzaGVldCIgaHJlZj0iaHR0cHM6Ly9jZG4uanNkZWxpdnIubmV0L2doL3B5dGhvbi12aXN1YWxpemF0aW9uL2ZvbGl1bS9mb2xpdW0vdGVtcGxhdGVzL2xlYWZsZXQuYXdlc29tZS5yb3RhdGUubWluLmNzcyIvPgogICAgCiAgICAgICAgICAgIDxtZXRhIG5hbWU9InZpZXdwb3J0IiBjb250ZW50PSJ3aWR0aD1kZXZpY2Utd2lkdGgsCiAgICAgICAgICAgICAgICBpbml0aWFsLXNjYWxlPTEuMCwgbWF4aW11bS1zY2FsZT0xLjAsIHVzZXItc2NhbGFibGU9bm8iIC8+CiAgICAgICAgICAgIDxzdHlsZT4KICAgICAgICAgICAgICAgICNtYXBfMWQyZGQ3ZTE4OWViNDdhODllZTRlZTUwM2NhYWI2YTUgewogICAgICAgICAgICAgICAgICAgIHBvc2l0aW9uOiByZWxhdGl2ZTsKICAgICAgICAgICAgICAgICAgICB3aWR0aDogMTAwLjAlOwogICAgICAgICAgICAgICAgICAgIGhlaWdodDogMTAwLjAlOwogICAgICAgICAgICAgICAgICAgIGxlZnQ6IDAuMCU7CiAgICAgICAgICAgICAgICAgICAgdG9wOiAwLjAlOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICA8L3N0eWxlPgogICAgICAgIAogICAgCiAgICAgICAgICAgICAgICA8c3R5bGU+CiAgICAgICAgICAgICAgICAgICAgLmxlYWZsZXQtaW1hZ2UtbGF5ZXIgewogICAgICAgICAgICAgICAgICAgICAgICAvKiBvbGQgYW5kcm9pZC9zYWZhcmkqLwogICAgICAgICAgICAgICAgICAgICAgICBpbWFnZS1yZW5kZXJpbmc6IC13ZWJraXQtb3B0aW1pemUtY29udHJhc3Q7CiAgICAgICAgICAgICAgICAgICAgICAgIGltYWdlLXJlbmRlcmluZzogY3Jpc3AtZWRnZXM7IC8qIHNhZmFyaSAqLwogICAgICAgICAgICAgICAgICAgICAgICBpbWFnZS1yZW5kZXJpbmc6IHBpeGVsYXRlZDsgLyogY2hyb21lICovCiAgICAgICAgICAgICAgICAgICAgICAgIGltYWdlLXJlbmRlcmluZzogLW1vei1jcmlzcC1lZGdlczsgLyogZmlyZWZveCAqLwogICAgICAgICAgICAgICAgICAgICAgICBpbWFnZS1yZW5kZXJpbmc6IC1vLWNyaXNwLWVkZ2VzOyAvKiBvcGVyYSAqLwogICAgICAgICAgICAgICAgICAgICAgICAtbXMtaW50ZXJwb2xhdGlvbi1tb2RlOiBuZWFyZXN0LW5laWdoYm9yOyAvKiBpZSAqLwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIDwvc3R5bGU+CiAgICAgICAgICAgIAo8L2hlYWQ+Cjxib2R5PiAgICAKICAgIAogICAgICAgICAgICA8ZGl2IGNsYXNzPSJmb2xpdW0tbWFwIiBpZD0ibWFwXzFkMmRkN2UxODllYjQ3YTg5ZWU0ZWU1MDNjYWFiNmE1IiA+PC9kaXY+CiAgICAgICAgCjwvYm9keT4KPHNjcmlwdD4gICAgCiAgICAKICAgICAgICAgICAgdmFyIG1hcF8xZDJkZDdlMTg5ZWI0N2E4OWVlNGVlNTAzY2FhYjZhNSA9IEwubWFwKAogICAgICAgICAgICAgICAgIm1hcF8xZDJkZDdlMTg5ZWI0N2E4OWVlNGVlNTAzY2FhYjZhNSIsCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgY2VudGVyOiBbMC4wLCAtOC41OTIyOTc2MDc2ODAwMDJlLTE3XSwKICAgICAgICAgICAgICAgICAgICBjcnM6IEwuQ1JTLkVQU0czODU3LAogICAgICAgICAgICAgICAgICAgIHp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LCAtMTgwLjBdLCBbOTAuMCwgMTgwLjBdXSwKICAgICAgICAgICAgICAgIHsib3BhY2l0eSI6IDAuMjV9CiAgICAgICAgICAgICkuYWRkVG8obWFwXzFkMmRkN2UxODllYjQ3YTg5ZWU0ZWU1MDNjYWFiNmE1KTsKICAgICAgICAKPC9zY3JpcHQ+ onload=\"this.contentDocument.open();this.contentDocument.write(atob(this.getAttribute('data-html')));this.contentDocument.close();\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe></div></div>"
      ],
      "text/plain": [
       "<folium.folium.Map at 0x7f0aac3bfe20>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "m = folium.Map(location=[lat.mean(), lon.mean()], zoom_start=1)\n",
    "\n",
    "folium.raster_layers.ImageOverlay(\n",
    "    image=colored_data,\n",
    "    bounds=[[lat.min(), lon.min()], [lat.max(), lon.max()]],\n",
    "    mercator_project=True,\n",
    "    opacity=0.25,\n",
    ").add_to(m)\n",
    "\n",
    "\n",
    "m"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Same as above but with cartopy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style=\"width:100%;\"><div style=\"position:relative;width:100%;height:0;padding-bottom:60%;\"><span style=\"color:#565656\">Make this Notebook Trusted to load map: File -> Trust Notebook</span><iframe src=\"about:blank\" style=\"position:absolute;width:100%;height:100%;left:0;top:0;border:none !important;\" data-html=PCFET0NUWVBFIGh0bWw+CjxoZWFkPiAgICAKICAgIDxtZXRhIGh0dHAtZXF1aXY9ImNvbnRlbnQtdHlwZSIgY29udGVudD0idGV4dC9odG1sOyBjaGFyc2V0PVVURi04IiAvPgogICAgCiAgICAgICAgPHNjcmlwdD4KICAgICAgICAgICAgTF9OT19UT1VDSCA9IGZhbHNlOwogICAgICAgICAgICBMX0RJU0FCTEVfM0QgPSBmYWxzZT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AgdG9wOiAwLjAlOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICA8L3N0eWxlPgogICAgICAgIAogICAgCiAgICAgICAgICAgICAgICA8c3R5bGU+CiAgICAgICAgICAgICAgICAgICAgLmxlYWZsZXQtaW1hZ2UtbGF5ZXIgewogICAgICAgICAgICAgICAgICAgICAgICAvKiBvbGQgYW5kcm9pZC9zYWZhcmkqLwogICAgICAgICAgICAgICAgICAgICAgICBpbWFnZS1yZW5kZXJpbmc6IC13ZWJraXQtb3B0aW1pemUtY29udHJhc3Q7CiAgICAgICAgICAgICAgICAgICAgICAgIGltYWdlLXJlbmRlcmluZzogY3Jpc3AtZWRnZXM7IC8qIHNhZmFyaSAqLwogICAgICAgICAgICAgICAgICAgICAgICBpbWFnZS1yZW5kZXJpbmc6IHBpeGVsYXRlZDsgLyogY2hyb21lICovCiAgICAgICAgICAgICAgICAgICAgICAgIGltYWdlLXJlbmRlcmluZzogLW1vei1jcmlzcC1lZGdlczsgLyogZmlyZWZveCAqLwogICAgICAgICAgICAgICAgICAgICAgICBpbWFnZS1yZW5kZXJpbmc6IC1vLWNyaXNwLWVkZ2VzOyAvKiBvcGVyYSAqLwogICAgICAgICAgICAgICAgICAgICAgICAtbXMtaW50ZXJwb2xhdGlvbi1tb2RlOiBuZWFyZXN0LW5laWdoYm9yOyAvKiBpZSAqLwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIDwvc3R5bGU+CiAgICAgICAgICAgIAo8L2hlYWQ+Cjxib2R5PiAgICAKICAgIAogICAgICAgICAgICA8ZGl2IGNsYXNzPSJmb2xpdW0tbWFwIiBpZD0ibWFwX2U5OWVlYWU2NzI3YTRkMTViMDE5MmZjYjQyMWE3OWUzIiA+PC9kaXY+CiAgICAgICAgCjwvYm9keT4KPHNjcmlwdD4gICAgCiAgICAKICAgICAgICAgICAgdmFyIG1hcF9lOTllZWFlNjcyN2E0ZDE1YjAxOTJmY2I0MjFhNzllMyA9IEwubWFwKAogICAgICAgICAgICAgICAgIm1hcF9lOTllZWFlNjcyN2E0ZDE1YjAxOTJmY2I0MjFhNzllMyIsCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgY2VudGVyOiBbMC4wLCAtOC41OTIyOTc2MDc2ODAwMDJlLTE3XSwKICAgICAgICAgICAgICAgICAgICBjcnM6IEwuQ1JTLkVQU0czODU3LAogICAgICAgICAgICAgICAgICAgIHpvb206IDEsCiAgICAgICAgICAgICAgICAgICAgem9vbUNvbnRyb2w6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgcHJlZmVyQ2FudmFzOiBmYWxzZSwKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgKTsKCiAgICAgICAgICAgIAoKICAgICAgICAKICAgIAogICAgICAgICAgICB2YXIgdGlsZV9sYXllcl9jNzk3ZWYwMGMyNjc0YWE1ODU1OWE2Y2E5YTE4ZTU2NiA9IEwudGlsZUxheWVyKAogICAgICAgICAgICAgICAgImh0dHBzOi8ve3N9LnRpbGUub3BlbnN0cmVldG1hcC5vcmcve3p9L3t4fS97eX0ucG5nIiwKICAgICAgICAgICAgICAgIHsiYXR0cmlidXRpb24iOiAiRGF0YSBieSBcdTAwMjZjb3B5OyBcdTAwM2NhIGhyZWY9XCJodHRwOi8vb3BlbnN0cmVldG1hcC5vcmdcIlx1MDAzZU9wZW5TdHJlZXRNYXBcdTAwM2MvYVx1MDAzZSwgdW5kZXIgXHUwMDNjYSBocmVmPVwiaHR0cDovL3d3dy5vcGVuc3RyZWV0bWFwLm9yZy9jb3B5cmlnaHRcIlx1MDAzZU9EYkxcdTAwM2MvYVx1MDAzZS4iLCAiZGV0ZWN0UmV0aW5hIjogZmFsc2UsICJtYXhOYXRpdmVab29tIjogMTgsICJtYXhab29tIjogMTgsICJtaW5ab29tIjogMCwgIm5vV3JhcCI6IGZhbHNlLCAib3BhY2l0eSI6IDEsICJzdWJkb21haW5zIjogImFiYyIsICJ0bXMiOiBmYWxzZX0KICAgICAgICAgICA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zbitjNGRkU3pqdlV1K3hna1J2ZWs0Ym5NeFBYRnlaNWVmTmZkaDJPLy94M3NNODl4NnFqdm5qUnkyY2RMalF6YWxBcklkdzMxbStnbi84VEZBbElOZ24zbU9VNWRRSnIxTHZ2WUpRRFA0SXlyalJuZFdSSGtzZzJDV3BkOXZLR3hZVEFHeDY1TUJRZXlJeEJuUjdZKzhIRFZ4eHNkSHdOamVIemttaVB3Y05YSEcvOXpISXJwdzROZU03NEVTWkFFU1pBRVNaQUVTWkQwK2c5SXVxSU9jY1d0ejI0aFBydnBMa0NJdXdDNm54VGlmcEx1VElhNE02bDczQ0h1Y2V2YmtoRGZsdWg3TjMwNUdRMGtyUVVJc1JaQXEwcENyQ3JSK3FRUTY1TzAwaTNFU2pldG1kVEMwbWdnYVIxM2lIWGNlaUpBajAxRUEwbFBLWVY0U2tuUHUrbWh3R2dnNlJuY0VNL2c2bWx1UGZJZURTVHRNS0Z0T0tLQnBGMXZ0RFZRTkpDMEU1ZTJLeE9rT1lPa2ZTYTFHV2Mwa0xUM3JUWUlGcVE1ZzZTZDNiWDl2U0ROR1NUOWJvbCszRVdRQk9sNmdxVGZiOU9QNEFtU0lGMVBrUFE3dC9xeFlFRVNKRUVTSkVFU0pJVWdDWklnQ1pJZ0NaSWdLUVJKa0FSSmtBUkprTnlOdndDU0kxU29CQW9oekFBQUFBQkpSVTVFcmtKZ2dnPT0iLAogICAgICAgICAgICAgICAgW1stOTAuMCwgLTE4MC4wXSwgWzkwLjAsIDE4MC4wXV0sCiAgICAgICAgICAgICAgICB7Im9wYWNpdHkiOiAwLjI1fQogICAgICAgICAgICApLmFkZFRvKG1hcF9lOTllZWFlNjcyN2E0ZDE1YjAxOTJmY2I0MjFhNzllMyk7CiAgICAgICAgCjwvc2NyaXB0Pg== onload=\"this.contentDocument.open();this.contentDocument.write(atob(this.getAttribute('data-html')));this.contentDocument.close();\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe></div></div>"
      ],
      "text/plain": [
       "<folium.folium.Map at 0x7f0a51b566d0>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import cartopy.crs as ccrs\n",
    "from cartopy.img_transform import warp_array\n",
    "\n",
    "source_extent = [lon.min(), lon.max(), lat.min(), lat.max()]\n",
    "\n",
    "new_data = warp_array(\n",
    "    colored_data,\n",
    "    target_proj=ccrs.GOOGLE_MERCATOR,\n",
    "    source_proj=ccrs.PlateCarree(),\n",
    "    target_res=data.shape,\n",
    "    source_extent=source_extent,\n",
    "    target_extent=None,\n",
    "    mask_extrapolated=False,\n",
    ")\n",
    "\n",
    "\n",
    "m = folium.Map(location=[lat.mean(), lon.mean()], zoom_start=1)\n",
    "\n",
    "folium.raster_layers.ImageOverlay(\n",
    "    image=new_data[0],\n",
    "    bounds=[[lat.min(), lon.min()], [lat.max(), lon.max()]],\n",
    "    opacity=0.25,\n",
    ").add_to(m)\n",
    "\n",
    "m"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "TODO: Try [rasterio](https://github.com/mapbox/rasterio/blob/ca75cf0a842943c1b3da4522e6ea3500215130fd/docs/reproject.rst).  Rasterio can warp images and arrays."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Compare to original"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "From https://scitools.org.uk/cartopy/docs/latest/gallery/waves.html\n",
    "\n",
    "![](https://scitools.org.uk/cartopy/docs/latest/_images/sphx_glr_waves_001.png)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
